import fetch from 'common/src/utils/fetch';
import UTILS from "common/src/utils/utils";
/** 课程分类管理*/
// 查询本科生指定分页的课程分类
export function getBclCourseCategoryList(params) {
  let query = '?'
  for (const key in params) {
    query += key
    query += '='
    query += params[key]
    query += '&'
  }
  return fetch({
    url: '/api/cultureservice/bclCoursesLabelGrade/page' + query,
    method: 'get'
  })
}

// 新增本科生课程分类
export function addBclCourseLabel(data) {
  return fetch({
    url: '/api/cultureservice/bclCoursesLabelGrade/insertGrade',
    method: 'post',
    headers: {
      'Content-Type': 'application/json'
    },
    data
  })
}
// 删除本科生课程分类
export function deleteBclCourseById(ids) {
  return fetch({
    url: '/api/cultureservice/bclCoursesLabelGrade/deleteGrade',
    method: 'post',
    headers: {
      'Content-Type': 'application/json'
    },
    data: ids
  })
}
// 查询本科生归属课程类别
export function findParentCourseLabel(data) {
  return fetch({
    url: 'api/cultureservice/bclCoursesLabelGrade/findParentCourseLabel',
    method: 'post',
    data
  })
}
// 本科新增课程类别
export function addCourseLab(data) {
  return fetch({
    url: 'api/cultureservice/bclCoursesLabelGrade/addCourseLab',
    method: 'post',
    data
  })
}
// 本科生课程类别更新
export function updateGrade(data) {
  return fetch({
    url: 'api/cultureservice/bclCoursesLabelGrade/updateGrade',
    method: 'post',
    data
  })
}


// 本科生按照条件查询课程类别
export function findcourseLab(data) {
  return fetch({
    url: 'api/cultureservice/bclCoursesLabelGrade/findcourseLab',
    method: 'post',
    data
  })
}
// 删除课程分类
export function deleteCourseLab(data) {
  return fetch({
    url: 'api/cultureservice/bclCoursesLabelGrade/deleteCourseLab',
    method: 'post',
    data
  })
}

// 新增课程
export function addCourseToCommonLab(data) {
  return fetch({
    url: 'api/cultureservice/bclCoursesLabelGrade/addCourseToCommonLab',
    method: 'post',
    data
  })
}
/**
 * 获取符合条件的开课学院
 */
export function getFacultys() {
  let data = {};
  data.isCourse = 1;
  data.currentState = 1;
  data.isUnderStudent = 1;
  return fetch({
    url: '/api/userservice/dept/list',
    method: 'post',
    data: data
  });
}
// 根据条件，分页查询课程
export function getCourseList(data) {
  return fetch({
    url: '/api/cultureservice/bclCourses/page',
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data
  })
}
// 查询公共课下边的课程
export function findCommonLabCourse(data) {
  return fetch({
    url: '/api/cultureservice/bclCoursesLabelGrade/findCommonLabCourse',
    method: 'post',
    data: data
  })
}
// 修改某个类别下的课程
export function updateCommonLabLabCourse(data) {
  return fetch({
    url: '/api/cultureservice/bclCoursesLabelGrade/updateCommonLabLabCourse',
    method: 'post',
    data: data
  });
}
// 修改某个课程类别
export function updateCourseLab(data) {
  return fetch({
    url: '/api/cultureservice/bclCoursesLabelGrade/updateCourseLab',
    method: 'post',
    data: data
  });
}
// 删除某个类别下的课程
export function deleteCourseToCommonLab(labid, courseCode) {
  return fetch({
    url: `/api/cultureservice/bclCoursesLabelGrade/deleteCourseToCommonLab?labid=${labid}&&courseCode=${courseCode}`,
    method: 'get'
  });
}
/**培养模板 */
// 查询培养模板列表
export function getCultureTemplateList(params) {
  let query = '?'
  for (const key in params) {
    query += key
    query += '='
    query += params[key]
    query += '&'
  }
  return fetch({
    url: '/api/cultureservice/bclCultureTemplate/page' + query,
    method: 'get'
  })
}
// 删除培养方案模板
export function deleteCultureTemplateById(ids) {
  return fetch({
    url: '/api/cultureservice/bclCultureTemplate',
    method: 'DELETE',
    headers: {
      'Content-Type': 'application/json'
    },
    data: {
      'idSet': ids
    }
  })
}
// 发布培养方案模板
export function pushCultureTemplateById(ids) {
  return fetch({
    url: '/api/cultureservice/bclCultureTemplate/release',
    method: 'PUT',
    headers: {
      'Content-Type': 'application/json'
    },
    data: {
      'idSet': ids
    }
  })
}
// 复制培养方案模板
export function copyCultureTemplate(data) {
  return fetch({
    url: '/api/cultureservice/bclCultureTemplate/copyCultureTemplate',
    method: 'POST',
    data
  })
}
//撤销已发布的
export function revertCultureTemplateById(id = '') {
  return fetch({
    url: `/api/cultureservice/bclCultureScheme/updateSchemeStatus?id=${id}`,
    method: 'get'
  })
}
// 保存模板
export function saveCultureTemplate(data) {
  let newData = Object.assign({}, data);
  if (newData.trainingCategory && newData.trainingCategory instanceof Array) {
    newData.trainingCategory = newData.trainingCategory.join(",");
  }
  return fetch({
    url: '/api/cultureservice/bclCultureTemplate',
    method: 'post',
    headers: {
      'Content-Type': 'application/json'
    },
    data: newData
  })
}
// 根据id查询培养方案模板基本信息
export function getCultureTemplateById(id) {
  return fetch({
    url: '/api/cultureservice/bclCultureTemplate/' + id,
    method: 'get'
  })
}
// 模板（方案）添加或者修改课程类别表单
export function saveCourseCategoryForm(data) {
  return fetch({
    url: '/api/cultureservice/bclCultureRule/batchUpdCultureRule',
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data
  })
}
// 根据模板（方案）id，查询出课程类别表单
export function getCourseCategoryFormById(id, type) {
  return fetch({
    url: '/api/cultureservice/bclCultureTemplate/coursesLabelList/' + id + '?type=' + type,
    method: 'GET'
  })
}
// （树形）课程类别列表条件查询，不分页
export function coursesLabelTreeList(params) {
  return fetch({
    url: '/api/cultureservice/bclCoursesLabel/coursesLabelTreeList',
    method: 'GET',
    params
  })
}

export function getCoursesLabelList(data) {
  return fetch({
      url: '/api/cultureservice/bclCoursesLabel/getCoursesLabelList',
      method: 'POST',
      data
  });
}

// 培养方案规则-模糊查询课程
export function findTamPleLab(params) {
  return fetch({
    url: '/api/cultureservice/bclCoursesLabel/findTamPleLab',
    method: 'GET',
    params
  })
}
// 新增本科生课程类别
export function batchSaveCultureRule(data) {
  return fetch({
    url: '/api/cultureservice/bclCultureRule/batchSaveCultureRule',
    method: 'POST',
    data
  })
}
// 查询模板已勾选的课程类别
export function findCheckedCultureLabelList(data) {
  return fetch({
    url: '/api/cultureservice/bclCultureRule/findCheckedCultureLabelList',
    method: 'POST',
    data
  })
}
/**
 *删除培养规则
 * @param {data} data
 */
export function deleteCultureRule(data) {
  return fetch({
    url: '/api/cultureservice/bclCultureRule/deleteCultureRule',
    method: 'delete',
    headers: {
      'Content-Type': 'application/json'
    },
    data
  });
}
// 根据模板（方案）id查询课程设置（课程表单）
export function courseLabelRelation(templateId, type) {
  return fetch({
    url: '/api/cultureservice/bclCourseLabelRelation/list/' + templateId + '?type=' + type,
    method: 'GET'
  })
}
// 增加课程设置（课程表单）
export function addCourse(data) {
  return fetch({
    url: '/api/cultureservice/bclCourseLabelRelation',
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data
  })
}
// 修改课程设置（课程表单）
export function EditCourse(data) {
  return fetch({
    url: '/api/cultureservice/bclCourseLabelRelation',
    method: 'PUT',
    headers: {
      'Content-Type': 'application/json'
    },
    data
  })
}
// 删除课程设置（培养方案课程表单）
export function deleteCourse(id) {
  return fetch({
    url: '/api/cultureservice/bclCourseLabelRelation/' + id,
    method: 'DELETE',
    headers: {
      'Content-Type': 'application/json'
    },
    data: {
      id: id
    }
  })
}
// 删除课程设置（培养模版课程表单）
export function clearAllChangeStatus(id) {
  return fetch({
    url: '/api/cultureservice/bclCourseLabelRelation/clearAllChangeStatus/' + id + '?type=1',
    method: 'GET'
  })
}
// 根据条件，分页查询课程
// export function getCourseList(data) {
//   return fetch({
//     url: '/api/cultureservice/bclCourses/page',
//     method: 'POST',
//     headers: {
//       'Content-Type': 'application/json'
//     },
//     data
//   })
// }
// 接口有变化
export function getCourseListNew(data) {
  return fetch({
    url: '/api/cultureservice/bclCourses/TrainingProgram_',
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data
  })
}
/**
 * 新增课程分组信息
 * @param data
 */
export function addCourseLabelRelGroup(data) {
  return fetch({
    url: '/api/cultureservice/bclCourseLabelRelGroup/addCourseLabelRelGroup',
    method: 'post',
    data
  })
}
/*
 * 当前培养方案分方向的数据
 * @param data
 */
export function findDirectionDataByScheme(id) {
  return fetch({
    url: '/api/cultureservice/bclCultureScheme/findDirectionDataByScheme?id=' + id,
    method: 'GET'
  })
}

/**
 * 新增课程方向
 * @param data
 */
export function addDirectionLableRelToCourse(data) {
  return fetch({
    url: '/api/cultureservice/bclDirectionLableRel/addDirectionLableRelToCourse',
    method: 'post',
    data
  })
}
/**
 * 删除课程方向
 * @param data
 */
export function delDirectionLableRelToCourse(data) {
  return fetch({
    url: '/api/cultureservice/bclDirectionLableRel/delDirectionLableRelToCourse',
    method: 'post',
    data
  })
}
/**
 *删除培养规则
 * @param {data} data
 */
export function deleteCourseLabelRelGroup(data) {
  return fetch({
    url: '/api/cultureservice/bclCourseLabelRelGroup/deleteCourseLabelRelGroup',
    method: 'delete',
    headers: {
      'Content-Type': 'application/json'
    },
    data
  })
}
/**
 * 获取章节内容（模板或方案）
 * @param data
 */


export function getSchemeChapters(params) {
  return fetch({

    url:
      '/api/cultureservice/bclCultureSchemeDetail/findCultScheDetailOrTemplateList',
    method: 'get',
    params: params
  })
}
/**
 * 更新章节内容（模板或方案）
 * @param data
 */
export function updateSchemeChapters(data) {
  return fetch({
    url:
      '/api/cultureservice/bclCultureSchemeDetail/upateCultScheDetailOrTemplate',
    method: 'post',
    data
  })
}
/**
 * 提交前校验章节内容（ 方案）
 * @param data
 */
export function checkCultScheDetail(data) {
  return fetch({
    url: '/api/cultureservice/bclCultureSchemeDetail/checkCultScheDetail',
    method: 'post',
    data
  })
}
/**
 * 新增表格内容
 * @param data
 */
export function getTableId(params) {
  return fetch({
    url: '/api/cultureservice/bclCultureSchemeDetail/addDetailTableByContentId',
    method: 'get',
    params: params
  })
}
/**
 * 查询某年某学院某专业的培养方案列表
 * @param data
 */
export function findCultureSchemeListByYear(data) {
  let newData = Object.assign({}, data);
  if (newData.trainingCategory && newData.trainingCategory instanceof Array) {
    newData.trainingCategory = newData.trainingCategory.join(",");
  }
  return fetch({
    url: '/api/cultureservice/bclCultureScheme/findCultureSchemeListByYear',
    method: 'post',
    data: newData
  })
}
/**
 * 查询培养方案列表
 * @param data
 */
export function findCultureSchemesByYear(data) {
  return fetch({
    url: '/api/cultureservice/bclCultureScheme/findCultureSchemesByYear',
    method: 'post',
    data: data
  })
}
/**
 * 获取培养方案的章节名称列表或章节内容
 * @param data
 */
export function findCultureScheDetailList(data) {
  return fetch({
    url: '/api/cultureservice/bclCultureSchemeDetail/findCultureScheDetailList',
    method: 'post',
    data
  })
}


/**开关设置 */
/**
 * 培养方案开关设置(查询)
 * @param data
 */
export function schemefindResult(data) {
  return fetch({
    url:
      '/api/cultureservice/bclSchemaSetTurn/findResult',
    method: 'post',
    data
  })
}
/**
 * 培养方案开关设置(提交)
 * @param data
 */
export function schemeAddSet(data) {
  return fetch({
    url:
      '/api/cultureservice/bclSchemaSetTurn/addSet',
    method: 'post',
    data
  })
}

/**
 * 培养方案开关设置(查询)
 * @param data
 */
export function findSchemePower(data) {
  return fetch({
    url:
      '/api/cultureservice/BclSchemePower/findSchemePower',
    method: 'post',
    data
  })
}
/**
 * 培养方案开关设置(新增)
 * @param data
 */
export function insertSchemePower(data) {
  return fetch({
    url:
      '/api/cultureservice/BclSchemePower/insertSchemePower',
    method: 'post',
    data
  })
}

/**
 * 培养方案开关设置(编辑)
 * @param data
 */
export function updateSchemePower(data) {
  return fetch({
    url:
      '/api/cultureservice/BclSchemePower/updateSchemePower',
    method: 'post',
    data
  })
}
/**
 * 培养方案开关设置(删除)
 * @param data
 */
export function deleteSchemePower(data) {
  return fetch({
    url:
      '/api/cultureservice/BclSchemePower/deleteSchemePower',
    method: 'post',
    data
  })
}
// 查询培养模板规则列表
export function queryCultureTemplateList(data) {
  return fetch({
    url: '/api/cultureservice/bclCultureTemplate/queryCultureTemplateList',
    method: 'post',
    headers: { 'Content-Type': 'application/json' },
    data
  });
}

// 查询培养规则列表
export function findCultureRex(data) {
  return fetch({
    url: '/api/cultureservice/BclCultureRex/findCultureRex',
    method: 'post',
    data
  });
}
//插入方案规则接口
export function inserBclCultureRex(data) {
  return fetch({
    url: '/api/cultureservice/BclCultureRex/inserBclCultureRex',
    method: 'post',
    data
  });
}
//编辑更新规则的接口
export function updateCultureRex(data) {
  return fetch({
    url: '/api/cultureservice/BclCultureRex/updateCultureRex',
    method: 'post',
    data
  });
}


/**批量修改 */
//获取角色分权
export function getPower() {
  return fetch({
    url: '/api/cultureservice/bclPowerContron/getPower',
    method: 'GET',
  });
}
export function findSchemeByTemID(id, size, page) {
  return fetch({
    url: '/api/cultureservice/bclCultureScheme/findSchemeByTemID?temID=' + id + '&pageSize=' + size + '&pageNum=' + page,
    method: 'GET',
  });
}
export function findSchemeByCondition(g, f, t, c, s, n) {
  return fetch({
    url: '/api/cultureservice/bclCultureScheme/findSchemeByCondition?grade=' + g + '&&faculty=' + f + '&&trainingLevel=' + t + '&&courseCode=' + c + '&&pageSize=' + s + '&&pageNum=' + n,
    method: 'GET',
  });
}
/**
 * 查询课程列表
 */
export function getCourses(data) {
  return fetch({
    url: '/api/cultureservice/bclCourses/page',
    method: 'POST',
    data
  });
}
/**
 * 培养方案列表
 */
export function findCultureSchemeList(data) {
  let newData = Object.assign({}, data);
  if (newData.trainingCategory && newData.trainingCategory instanceof Array) {
    newData.trainingCategory = newData.trainingCategory.join(",");
  }
  return fetch({
    url: '/api/cultureservice/bclCultureScheme/findCultureSchemeList',
    method: 'post',
    data: newData
  })
}


/**
 * 查询模板的课程类别 -- 只取叶子节点
 * @param data
 */
export function findCoursesLabelList(id) {
  return fetch({
    url:
      '/api/cultureservice/bclCultureScheme/findSchemeLab?schemeID2S=' + id,
    method: 'GET'
  })
}
/**
 * 查询章节样例 -- 查询当前模板的章节样例
 * @param data
 */
export function findContentList(id) {
  return fetch({
    url: '/api/cultureservice/bclCultureScheme/findNodeList?cultureIdList=' + id,
    method: 'GET'
  })
}
/**
 * 批量编辑
 * @param data
 */
export function findSchemeCourse(id, code, pageNum_, pageSize_) {
  return fetch({
    url: '/api/cultureservice/bclCultureScheme/findSchemeCourseCode?schemeID2S=' + id + '&&condition=' + code + '&pageNum=' + pageNum_ + '&pageSize=' + pageSize_,
    method: 'get',
  })
}
/**
 * 批量编辑
 * @param data
 */
export function findSchemeCourseTwo(id, code, pageNum_, pageSize_) {
  return fetch({
    url: '/api/cultureservice/bclCultureScheme/findSchemeCourse?schemeID2S=' + id + '&&condition=' + code + '&pageNum=' + pageNum_ + '&pageSize=' + pageSize_,
    method: 'get',
  })
}
// 新课程的列表 新增课程的列表
export function newCoursePageList(id, code) {
  return fetch({
    url: '/api/cultureservice/bclCourses/page?schemeID2S=' + id + '&&courseCode=' + code,
    method: 'POST'
  })
}
/**
 * 批量编辑保存
 * @param data
 */
export function saveCourseInfo(data, singleElection) {
  return fetch({
    url: `/api/cultureservice/bclCourseLabelRelation/saveCourseInfo/${singleElection}`,
    method: 'post',
    data
  })
}
/**
 * 批量新增课程
 * @param data
 */
export function batchAddCourses(data, singleElection) {
  return fetch({
    url: `/api/cultureservice/bclCultureScheme/batchAddCourses/${singleElection}`,
    method: 'post',
    data
  })
}

/**
 * 批量替换课程
 * @param data
 */
export function batchReplaceCourses(data, singleElection) {
  return fetch({
    url: `/api/cultureservice/bclCultureScheme/batchReplaceCourses/${singleElection}`,
    method: 'post',
    data
  })
}
/**
 * 批量删除课程
 * @param data
 */
export function batchDelCourses(data, singleElection) {
  return fetch({
    url: `/api/cultureservice/bclCultureScheme/batchDelCourses/${singleElection}`,
    method: 'post',
    data
  })
}
/**
 * 批量课程编辑保存
 * @param data
 */
export function saveCourseInfoByRelationIds(data, singleElection) {
  return fetch({
    url: `/api/cultureservice/bclCourseLabelRelation/saveCourseInfoByRelationIds/${singleElection}`,
    method: 'post',
    data
  })
}
/**
 * 批量课程替换课程
 * @param data
 */
export function batchReplaceCoursesByRelationIds(data, singleElection) {
  return fetch({
    url: `/api/cultureservice/bclCultureScheme/batchReplaceCoursesByRelationIds/${singleElection}`,
    method: 'post',
    data
  })
}
/**
 * 批量课程删除课程
 * @param data
 */
export function batchDelCoursesByRelationIds(data, singleElection) {
  return fetch({
    url: `/api/cultureservice/bclCultureScheme/batchDelCoursesByRelationIds/${singleElection}`,
    method: 'post',
    data
  })
}
/**
 * 批量修改章节样例
 * @param data
 */
export function batchEditContents(data) {
  return fetch({
    url: '/api/cultureservice/bclCultureScheme/updateCultureTemolateContent',
    method: 'post',
    data
  })
}
// 培养管理
/**
 * 查询专业对应的大类培养方案列表
 * @param data
 */
export function findTrainingCategoryScheme(data) {
  return fetch({
    url: '/api/cultureservice/bclCultureScheme/findCategoryScheme',
    method: 'post',
    data
  })
}


/**
 * 培养方案模板根据条件查询不分页——new
 * @param data
 */
export function cultureTemplateListNew(data) {
  let newData = Object.assign({}, data);
  if (newData.trainingCategory && newData.trainingCategory instanceof Array) {
    newData.trainingCategory = newData.trainingCategory.join(",");
  }
  return fetch({
    url: '/api/cultureservice/bclCultureTemplate/cultureTemplateListNew',
    method: 'post',
    data: newData
  })
}

/**
 * 查询单个培养方案
 * @param data
 */
export function findCultureSchemeById(params) {
  return fetch({
    url: '/api/cultureservice/bclCultureScheme/findCultureSchemeById',
    method: 'get',
    params: params
  })
}
// 根据Id查看模板详情
export function getTemplateById(id) {
  return fetch({
    url: '/api/cultureservice/bclCultureTemplate/convert/' + id + '?',
    method: 'GET'
  })
}
/**
 * 修改培养方案
 */
export function updateCultureScheme(data) {
  let newData = Object.assign({}, data);
  if (newData.trainingCategory && newData.trainingCategory instanceof Array) {
    newData.trainingCategory = newData.trainingCategory.join(",");
  }
  return fetch({
    url: '/api/cultureservice/bclCultureScheme/updateCultureScheme',
    method: 'put',
    data: newData
  })
}
/**
 * 查询校内专业
 * @param data
 */
export function findProfessionByParam(data) {
  if (data) {
      data.pageSize_ = 100
  }
  return fetch({
     url: '/api/commonservice/campusProfession/findCampusProfessionList',
     method: 'post',
     data
   // url: '/api/baseresservice/campusProfession/findProfessionByDeptCode?grade=' + grade + '&faculty=' + faculty,
   // method: 'get',
  })
}
/**
 * 查询校内专业（专业大类）
 * @param data
 */
export function findBelongBigProfessionByFaculty(data) {
    if (data) {
        data.pageSize_ = 100
    }
  return fetch({
    url: '/api/commonservice/campusProfession/findCampusProfessionList',
    method: 'POST',
    data
  })
}

/**
 * 查询方案下各方向详细信息（可查询单个或所有方向）
 */
export function findDirectionLableRel(schemeId, directionCode) {
  return fetch({
    url: '/api/cultureservice/bclDirectionLableRel/findDirectionLableRel?schemeId=' + schemeId + "&directionCode=" + directionCode,
    method: 'GET'
  })
}
/**
 * 修改/新增/编辑
 */
export function editDirDataByScheme(data) {
  return fetch({
    url: '/api/cultureservice/bclDirectionLableRel/editDirectionDataByScheme',
    method: 'POST',
    data
  })
}
/**
 * 查询方案下方向code和方案名称
 */
export function findDirBySchemeId(schemeId) {
  return fetch({
    url: '/api/cultureservice/bclDirectionLableRel/findDirectionByDirection?schemeId=' + schemeId,
    method: 'GET'
  })
}
/**
 * 查询方案下各方向详细信息（所有方向）
 */
export function findAllDirection(schemeId) {
  return fetch({
    url: '/api/cultureservice/bclDirectionLableRel/findDirectionLableRel?schemeId=' + schemeId,
    method: 'GET'
  })
}
/**
 * 删除
 */
export function delAllDirection(schemeId) {
  return fetch({
    url: '/api/cultureservice/bclDirectionLableRel/deleteDirectionDataByScheme?schemeId=' + schemeId,
    method: 'DELETE'
  })
}
/**
 * 新增培养方案
 */
export function addCultureScheme(data) {
  let newData = Object.assign({}, data);
  if (newData.trainingCategory && newData.trainingCategory instanceof Array) {
    newData.trainingCategory = newData.trainingCategory.join(",");
  }
  return fetch({
    url: '/api/cultureservice/bclCultureScheme/addCultureScheme',
    method: 'post',
    data: newData
  })
}
// /**
//  * 查询专业对应的大类培养方案列表
//  * @param data
//  */
// export function findTrainingCategoryScheme(data) {
//   return fetch({
//     url: '/api/cultureservice/bclCultureScheme/findTrainingCategoryScheme',
//     method: 'post',
//     data
//   })
// }
/**
 * 查询模板列表
 * @param data
 */
export function cultureTemplateList(params) {
  return fetch({
    url: '/api/cultureservice/bclCultureTemplate/cultureTemplateList',
    method: 'get',
    params: params
  })
}
/**
 * 提交培养方案审批
 * @param data
 */
export function checkCultureScheme(data) {
  return fetch({
    url: '/api/cultureservice/bclCultureScheme/checkCultureScheme',
    method: 'post',
    data
  })
}
/**
 * 点击培养方案变更按钮
 * @param data
 */
export function changeCultureScheme(data) {
  return fetch({
    url: '/api/cultureservice/bclCultureScheme/changeCultureScheme',
    method: 'get',
    params: {
      id: data.id,
      isSynchronousPlan: data.isSynchronousPlan,
    },
  })
}
/**
 * 删除培养方案
 */
export function batchDelCultureScheme(data) {
  return fetch({
    url: '/api/cultureservice/bclCultureScheme/batchDelCultureScheme',
    method: 'delete',
    data
  })
}
/**
 * 获取删除的结果key
 */
export function getResult(key) {
  return fetch({
    url: '/api/cultureservice/bclCultureScheme/result/' + key,
    method: 'GET',
    showMask: false
  });
}
/**
 * 导出培养方案
 * @param {Object} params
 */
export function schemeListExport(params) {
  const url = '/api/cultureservice/bclCultureScheme/exportCultureSchemeZip'
  const remove_params = ['pageNum_', 'pageSize_']
  let queryParam = ''
  for (const key in params) {
    // 去掉分页
    if (remove_params.includes(key)) {
      continue
    }
    // 去掉空参数
    if (params[key] == '') {
      continue
    }
    queryParam += `${key}=${params[key]}&`
  }
  window.open(`${url}?${queryParam}`)
}
/**
 * 批量新增培养方案
 * @param data
 */
export function batchAddCultureScheme(data) {
  return fetch({
    url: '/api/cultureservice/bclCultureScheme/batchAddCultureScheme',
    method: 'post',
    data
  })
}
//复制之前(课程设置) 本科生
export function copyLabelCourseRelation(data){
  return fetch({
    url:'/api/cultureservice/bclCourseLabelRelation/copyLabelCourseRelation',
    method:'POST',
    data
  })
}

// 复制之前（课程设置）研究生
export function copyBackCourseLabelRelation(data) {
  return fetch({
    url: '/api/cultureservice/bclCourseLabelRelation/copyBackCourseLabelRelation',
    method: 'POST',
    data
  })
}
/**培养方案查询*/
export function findCultureSchemeListForMange(data) {
  let newData = Object.assign({}, data);
  if (newData.trainingCategory && newData.trainingCategory instanceof Array) {
    newData.trainingCategory = newData.trainingCategory.join(",");
  }
  return fetch({
    url: '/api/cultureservice/bclCultureScheme/cultureSchemeListForMange',
    method: 'post',
    data: newData
  })
}
/**
 * 培养方案导出pdf或者word压缩包
 * @param {Object} params
 */
export function exportCultureSchemePdfOrWordZip(params) {
  const url = '/api/cultureservice/bclCultureScheme/exportCultureSchemePdfOrWordZip';
  let queryParams = '';
  for (let item in params) {
    if (params[item] === '') {
      continue;
    }
    queryParams += `${item}=${params[item]}&`;
  }
  queryParams = queryParams.substring(0, queryParams.lastIndexOf('&'));
  window.open(`${url}?${queryParams}`);
}
/**我的培养方案 */
export function queryStudentCultureScheme(id) {
  return fetch({
    url: '/api/cultureservice/bclStudentCultureRel/queryStudentCultureScheme?stuid=' + id,
    method: 'get'
  })
}
// 本科生按照条件查询课程标签
export function bclCoursesTag(data) {
  return fetch({
    url: 'api/cultureservice/bclCoursesTag/list',
    method: 'post',
    data
  })
}
// 查询本科生课程标签类别
export function listParent(data) {
  return fetch({
    url: 'api/cultureservice/bclCoursesTag/listParent',
    method: 'post',
    data
  })
}
// 新增本科生课程标签类别
export function addCourseTag(data) {
  return fetch({
    url: 'api/cultureservice/bclCoursesTag/addCourseTag',
    method: 'post',
    data
  })
}
// 修改本科生课程标签类别
export function updateCourseTag(data) {
  return fetch({
    url: 'api/cultureservice/bclCoursesTag/updateCourseTag',
    method: 'post',
    data
  })
}
// 删除本科生课程标签类别
export function deleteCourseTag(id) {
  return fetch({
    url: 'api/cultureservice/bclCoursesTag/deleteCourseTag/' + id,
    method: 'get'
  })
}
// 查询本科生课程荣誉模块
export function bclHonorModuleList(data) {
  return fetch({
    url: 'api/cultureservice/bclHonorModule/listHonorModule',
    method: 'post',
    data
  })
}
// 新增本科生课程荣誉模块
export function addHonorModule(data) {
  return fetch({
    url: 'api/cultureservice/bclHonorModule/addHonorModule',
    method: 'post',
    data
  })
}
// 修改本科生课程荣誉模块
export function updateHonorModule(data) {
  return fetch({
    url: 'api/cultureservice/bclHonorModule/updateHonorModule',
    method: 'post',
    data
  })
}
// 查询本科生课程荣誉模块
export function listHonorModuleParent(data) {
  return fetch({
    url: 'api/cultureservice/bclHonorModule/listHonorModuleParent',
    method: 'post',
    data
  })
}
// 删除本科生课程荣誉模块
export function deleteHonorModule(id) {
  return fetch({
    url: 'api/cultureservice/bclHonorModule/deleteHonorModule/' + id,
    method: 'get'
  })
}
// 查询本科生课程荣誉模块课程
export function honorModuleCourselist(data) {
  return fetch({
    url: 'api/cultureservice/bclHonorModule/courselist',
    method: 'post',
    data
  })
}
// 查询本科生课程荣誉模块父子课程
export function findNameByid(id) {
  return fetch({
    url: 'api/cultureservice/bclHonorModule/findNameByid/' + id,
    method: 'get'
  })
}
// 新增本科生课程荣誉模块课程
export function addHonorModuleCourse(data) {
  return fetch({
    url: 'api/cultureservice/bclHonorModule/addHonorModuleCourse',
    method: 'post',
    data
  })
}
// 查询本科生课程荣誉模块课程维护中的替换课程
export function findCourseByid(id) {
  return fetch({
    url: 'api/cultureservice/bclHonorModule/findCourseByid/' + id,
    method: 'get'
  })
}
// 修改本科生课程荣誉模块
export function updateHonorModuleCourse(data) {
  return fetch({
    url: 'api/cultureservice/bclHonorModule/updateHonorModuleCourse',
    method: 'post',
    data
  })
}
// 删除本科生课程荣誉模块课程维护中的课程
export function deleteHonorModuleCourse(id) {
  return fetch({
    url: 'api/cultureservice/bclHonorModule/deleteHonorModuleCourse/' + id,
    method: 'get'
  })
}
export function exportHonorModuleCourse(data) {
  window.open('/api/cultureservice/bclHonorModule/exportHonorModuleCourse' + getParams(data))
}
// 查询本科生课程类别课程表前
export function findCourseTagName(data) {
  return fetch({
    url: 'api/cultureservice/bclCoursesTag/findCourseTagName',
    method: 'post',
    data
  })
}
// 查询本科生课程类别课程表前
export function findCourseTagNameByGrade(year, id) {
  return fetch({
      url:
          'api/cultureservice/bclCoursesTag/findCourseTagNameByGrade?grade=' +
          year +
          '&trainingLevel=' +
          id,
      method: 'get'
  })
}
// 查询本科生培养方案规则查询公选课类别
export function findPublicElectiveByGrade(year, id) {
  return fetch({
    url: 'api/cultureservice/BclCultureRex/findPublicElectiveByGrade/' + year + '/' + id,
    method: 'get'
  })

}
// 新增本科生培养方案规则
export function insertBclCultureRule(data) {
  return fetch({
    url: 'api/cultureservice/BclCultureRex/insertBclCultureRule',
    method: 'post',
    data
  })
}
// 查询本科生培养方案规则
export function findBclCultureRule(data) {
  return fetch({
    url: 'api/cultureservice/BclCultureRex/findBclCultureRule',
    method: 'post',
    data
  })
}
// 本科生培养方案规则编辑回填
export function findBclCultureRuleDetail(id) {
  return fetch({
    url: 'api/cultureservice//BclCultureRex/findBclCultureRuleDetail/' + id,
    method: 'get'
  })
}
// 编辑本科生培养方案规则
export function updateBclCultureRule(data) {
  return fetch({
    url: 'api/cultureservice/BclCultureRex/updateBclCultureRule',
    method: 'post',
    data
  })
}
// 删除本科生培养方案规则
export function deleteBclCultureRule(id, templateID) {
  return fetch({
    url: 'api/cultureservice/BclCultureRex/deleteBclCultureRule/' + id + '/' + templateID,
    method: 'get'
  })
}

//查询课程类别
export function findLabelInfoByCultureId(id) {
  return fetch({
    url: 'api/cultureservice/bclCultureScheme/findLabelInfoByCultureId?cultureId=' + id,
    method: 'get'
  })
}
//课程设置-方向下添加课程重复校验
export function checkRepeatedMultiDirection(params){
  return fetch({
    url:`api/cultureservice/bclCourseLabelRelation/checkRepeatedMultiDirection/${params.trainingID}/${params.directionCode}/${params.courseCodes}`,
    method:'get'
  })
}

function getParams(params) {
  var paramsData = [];
  for (const key in params) {
    params[key] &&
      paramsData.push(
        key + '=' + params[key]
      );
  }
  if (paramsData.length)
    return '?' + paramsData.join('&');
  else
    return '';
}
/**
 * 批量修改培养方案导出
 * @param {*} data 
 */
export function exportProgram(data){
    return fetch({
        url: `/api/cultureservice/bclCultureScheme/exportCultureSchemeCourseInfoList`,
        method: 'post',
        data: data,
        responseType: 'blob'
    }).then(res => {
        UTILS.downloadFile(res, '培养方案列表.xls', 'application/vnd.ms-excel;charset=utf-8');
    });
}
//批量修改培养方案-查询课程子类别
export function findGradeListByTemplate(id) {
  return fetch({
    url: 'api/cultureservice/bclCultureTemplate/findGradeListByTemplate?templateId=' + id,
    method: 'get'
  })
}


// 培养方案管理
// 培养方案 复制
export function copyCultureScheme(data) {
  return fetch({
    url: '/api/cultureservice/bclCultureScheme/copyCultureScheme',
    method: 'POST',
    data
  })
}
/**
 * 查询批量修改培养方案
 * @param data
 */
export function getSchemeCategory(id) {
  return fetch({
    url:
      '/api/cultureservice/bclCultureScheme/getSchemeCategory?schemeIds=' + id,
    method: 'GET'
  })
}
/**
 * 课程考核方式查询
 * @param data
 */
export function findCoursesByGrade(data) {
  return fetch({
    url: ' /api/cultureservice/bclCourses/findCoursesByGrade',
    method: 'post',
    data
  })
}
/**
 * 课程考核方式查询(查看详情)
 * @param data
 */
export function findCoursesAssessmentMode(data) {
  return fetch({
    url: ' /api/cultureservice/bclCourses/findCoursesAssessmentMode',
    method: 'post',
    data
  })
}
/**
 * 查询培养方案学期
 * @param data
 */
export function getSchemeSchoolTerm(id) {
  return fetch({
    url:
      '/api/cultureservice/bclCultureScheme/getSchemeSchoolTerm?id=' + id,
    method: 'GET'
  })
}
/**
 * 批量查询培养方案学期
 * @param data
 */
export function getSchemeSchoolTermByIds(id) {
  return fetch({
    url:
      ' /api/cultureservice/bclCultureScheme/getSchemeSchoolTermByIds?ids=' + id,
    method: 'GET'
  })
}
/**
 * 查询培养方案学期课程
 * @param data
 */
export function findCourseLabelRelationBySemesters(id, semesters) {
  return fetch({
      url:
          '  /api/cultureservice/bclCourseLabelRelation/findCourseLabelRelationBySemesters/' +
          id +
          '?' +
          'semesters=' +
          semesters +
          '&type=2',
      method: 'GET'
  })
}
/**
 * 课表-是否显示申请还是撤回按钮
 * @param data
 */
export function canAuditOption(id, calendarId) {
  return fetch({
      url:
          ' /api/cultureservice/bclCulturePlan/canAuditOption?studentId=' +
          id +
          '&calendarId=' +
          calendarId,
      method: 'GET'
  })
}
/**
 * 排课课程-提交到计划
 * @param data
 */
export function checkPlanCourse(data) {
  return fetch({
    url: ' /api/cultureservice/bclCulturePlan/checkPlanCourse',
    method: 'post',
    data
  })
}
/**
 * 课表-是否显示申请还是撤回按钮
 * @param data
 */
export function recallElePlanCourse(id, calendarId) {
  return fetch({
      url:
          ' /api/cultureservice/bclCulturePlan/recallElePlanCourse?studentId=' +
          id +
          '&calendarId=' +
          calendarId,
      method: 'GET'
  })
}
/**
 * 培养方案 -- 比对
 * @param data
 */
export function compareCultureScheme(id, compareId, semesters) {
  return fetch({
    url:
        '/api/cultureservice/bclCultureScheme/compareCultureScheme?originId=' + 
        id +
        '&compareId=' + 
        compareId +
        '&semesters=' + 
        semesters,
    method: 'GET'
  })
}
/**
 * 培养方案课程表单-批量删除
 * @param data
 */
export function batchDelCourseLabeRalation(schemeId, ids) {
  return fetch({
    url: `/api/cultureservice/bclCourseLabelRelation/batchDelCourseLabeRalation/${schemeId}/${ids}`,
    method: 'GET'
  })
}
/**
 * 取消培养方案变更
 * @param data
 */
export function cancelChangeCultureScheme(id) {
  return fetch({
    url:
      ' /api/cultureservice//bclCultureScheme/cancelChangeCultureScheme?id=' + id,
    method: 'GET'
  })
}

// 培养方案和模板批量编辑课程
export function batchUpdateCourseLabelRelation(data) {
    return fetch({
        url: '/api/cultureservice/bclCourseLabelRelation/batchUpdateCourseLabelRelation',
        method: 'put',
        data
    })
}
export function getApprovalCultureList(data) {
  return fetch({
      url: '/api/cultureservice/bclCultureScheme/getApprovalCultureList',
      method: 'post',
      data
  })
}